﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace SceneEditor
{
    public partial class Editor
    {
        private void cbOrientation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (editor.cbOrientation.SelectedIndex == 0)
                gizmo.Oritentation = GizmoOrientation.World;
            else if (editor.cbOrientation.SelectedIndex == 1)
                gizmo.Oritentation = GizmoOrientation.Local;
            else
            {
                gizmo.Oritentation = GizmoOrientation.Camera;
            }
        }

        private void btnSnapToGrid_Click(object sender, EventArgs e)
        {
            editor.btnSnapToGrid.Checked = !editor.btnSnapToGrid.Checked;
            gizmo.SnapToGrid = editor.btnSnapToGrid.Checked;
        }

        private void cbOrigin_SelectedIndexChanged(object sender, EventArgs e)
        {
            gizmo.Transforms.WorldOrigin = editor.cbOrigin.SelectedIndex == 0;
        }

        private void cbRotationMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            gizmo.Transforms.RotatePerObject = editor.cbRotationMode.SelectedIndex == 0;
        }

        private void btnScale_Click(object sender, EventArgs e)
        {
            if (gizmo.GizmoMode != GizmoMode.Scale)
            {
                editor.btnScale.Checked = true;
                editor.btnRotate.Checked = false;
                editor.btnTranslate.Checked = false;

                gizmo.GizmoMode = GizmoMode.Scale;
            }
        }
        private void btnRotate_Click(object sender, EventArgs e)
        {
            if (gizmo.GizmoMode != GizmoMode.Rotate)
            {
                editor.btnRotate.Checked = true;
                editor.btnTranslate.Checked = false;
                editor.btnScale.Checked = false;

                gizmo.GizmoMode = GizmoMode.Rotate;
            }
        }
        private void btnTranslate_Click(object sender, EventArgs e)
        {
            if (gizmo.GizmoMode != GizmoMode.Translate)
            {
                editor.btnTranslate.Checked = true;
                editor.btnRotate.Checked = false;
                editor.btnScale.Checked = false;

                gizmo.GizmoMode = GizmoMode.Translate;
            }
        }
    }
}
